/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2023-10-20 15:56:04
 * @LastEditors: TT-hzy
 * @LastEditTime: 2024-07-26 15:52:14
 */

import 'package:hzy_project_template/config/theme_config/hzy_theme_data_config.dart';

import '../config/data_config/hzy_sp_id_config.dart';
import 'shared_preferences_tool.dart';

class HzySpTool {
  /// 存App 是否第一次安装
  static Future<bool> saveAppFirstInstall({
    required bool type,
  }) async {
    return await SharedPreferencesTool.putBool(
          HzySpIdConfig.appFirstInstall,
          type,
        ) ??
        false;
  }

  /// 取App 是否第一次安装
  static bool getAppFirstInstall() {
    return SharedPreferencesTool.getBool(
          HzySpIdConfig.appFirstInstall,
        ) ??
        true;
  }

  /// 存用户信息
  static Future<bool> saveUserInfo({
    dynamic info,
    String? account,
  }) async {
    return await SharedPreferencesTool.putObject(
          account ?? HzySpIdConfig.userInfo,
          info,
        ) ??
        false;
  }

  /// 取用户信息
  static getUserInfo({
    String? account,
  }) {
    return SharedPreferencesTool.getObject(
      account ?? HzySpIdConfig.userInfo,
    );
  }

  /// 存token
  static saveToken({
    required String token,
  }) async {
    return await SharedPreferencesTool.putString(
          HzySpIdConfig.token,
          token,
        ) ??
        false;
  }

  /// 取token
  static getToken() {
    return SharedPreferencesTool.getString(
      HzySpIdConfig.token,
    );
  }

  /// 存主题
  /// 0 白色
  /// 1 黑色
  /// 2 跟随系统
  static Future<bool> saveThemeType({
    required int type,
  }) async {
    return await SharedPreferencesTool.putInt(
          HzySpIdConfig.themeType,
          type,
        ) ??
        false;
  }

  /// 取主题
  /// 0 白色
  /// 1 黑色
  /// 2 跟随系统
  static int themeType() {
    return SharedPreferencesTool.getInt(HzySpIdConfig.themeType,
            defValue: normlThemeType) ??
        normlThemeType;
  }

  /// 存语言配置
  /// zh_CN 中文
  /// en_US 英文
  static saveLauchType({
    required String launch,
  }) {
    return SharedPreferencesTool.putString(
      HzySpIdConfig.launchType,
      launch,
    );
  }

  /// 获取语言配置
  /// zh_CN 中文
  /// en_US 英文
  static String getLaunchType() {
    return SharedPreferencesTool.getString(
          HzySpIdConfig.launchType,
        ) ??
        "zh_CN";
  }

  /// 清除key

  static Future<bool>? removeKey({
    required String key,
  }) {
    return SharedPreferencesTool.remove(key);
  }
}
